package com.sunlands.qdcy.tongzhuo.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import java.util.Date;

/**
 * @author anjl
 * @date 2019/5/2914:21
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity(name = "tz_user_diary")
@JsonSerialize
@DynamicUpdate
@DynamicInsert
public class DiaryDO {

    public static final String FILED_CREATE_TIME = "createTime";
    public static final String FILED_CREATE_TYPE = "createType";
    public static final String FILED_SEE_BY_MYSELF = "seeByMyself";
    public static final String FILED_USER_ID = "userId";
    public static final String FILED_TOPIC_ID = "topicId";
    @Id
    @GeneratedValue
    @ApiModelProperty(value = "日记id")
    private Long id;

    @ApiModelProperty(value = "用户ID")
    private Long userId;

    @ApiModelProperty(value = "日记内容")
    private String content;

    @ApiModelProperty(value = "图片内容，多个逗号分隔")
    private String imgUrls;

    @ApiModelProperty(value = "视频内容，多个逗号分隔")
    private String videoUrls;

    @ApiModelProperty(value = "话题id")
    private Long topicId;

    @ApiModelProperty(value = "话题名称")
    private String topicName;

    @ApiModelProperty(value = "0自建  1转发")
    private Integer createType;

    @ApiModelProperty(value = "转发的ID，标记从哪条日记转发的")
    private Long forwardId;

    @ApiModelProperty(value = "根日记id，标记最终那条create_type=0自建类型的日记")
    private Long rootId;

    @CreationTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @UpdateTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "仅自己可见 1 是 0否")
    private Integer seeByMyself;

    @SuppressWarnings("all")
    public enum CreateTypeEnums {
        CREATE_BY_SELF(0),
        FORWARD(1),
        DELETE(-1);
        public final Integer type;
        CreateTypeEnums(Integer type) {
            this.type = type;
        }
    }

}
